<template>
  <div>
    <div class="radio">
      <el-radio-group v-model="PatentType" size="mini" @input="radioUpdate">
        <el-radio-button label="0">专利奖 {{ PatentNumber.patent }}</el-radio-button>
        <el-radio-button label="1">国家示范企业 {{ PatentNumber.patent_num1 }}</el-radio-button>
        <el-radio-button label="2">省级示范企业 {{ PatentNumber.patent_num2 }}</el-radio-button>
        <el-radio-button label="3">国家优势企业 {{ PatentNumber.patent_num3 }}</el-radio-button>
      </el-radio-group>
    </div>

    <el-table :data="tableData" style="width: 100%">
      <el-table-column v-if="PatentType == 0" prop="name" label="名称" width="180">
      </el-table-column>
      <el-table-column v-else prop="company" label="公司名称" width="180">
      </el-table-column>
      <el-table-column v-if="PatentType == 0" prop="ano" label="专利号" width="180">
      </el-table-column>
      <el-table-column prop="years" label="年份" width="180">
      </el-table-column>
      <el-table-column v-if="PatentType == 0" prop="prize_name" label="荣誉">
      </el-table-column>
      <el-table-column v-else prop="des" label="荣誉">
      </el-table-column>
    </el-table>

    <div class="pagination">
      <el-pagination background small @current-change="handleCurrentChange" :current-page="page" :page-size="5"
        layout="total, prev, pager, next, jumper" :total="parseInt(count)" align="left" :pager-count="5">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { honorlist } from '@/api/newuser'
export default {
  data() {
    return {
      id: this.$route.query.id,
      tableData: [],
      PatentType: '0',
      page: 1,
      count: 0,
    }
  },
  props: {
    PatentNumber:{
      type: Object,
      default: () => ({})
    },
    form_admin: {
      handler(newV, oldV) {
        this.honorlist()
      },
      deep: true,
    },
  },
  components: {},
  mounted() {
    this.honorlist()
  },
  methods: {
    honorlist() { 
      console.log(this.form_admin,'asdasguiyh');
      honorlist({
        id: this.form_admin.id,
        type: this.PatentType,
        page: this.page,
        company_name: this.form_admin.company
      }).then(res => {
        this.tableData = res.list
        this.count = res.count
      })
    },
    radioUpdate(index) {
      // console.log(index);
      this.PatentType = index
      this.page = 1
      this.count = 0
      this.honorlist()
    },
    handleCurrentChange(currentPage){
      this.page = currentPage
      this.honorlist()
    }
  },
};
</script>

<style scoped lang="less">
.pagination {
  margin: 10px auto;
}
@media (max-width: 1360px) {}

@media (max-width: 1280px) {}

@media (max-width: 768px) {}
</style>
